 
package com.ysd.web.daoimpl;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

import com.ysd.web.db.DBManager;
import com.ysd.web.entity.Product;
import com.ysd.web.entity.ProductImage;

public class ProductimageDaoimpl {
	public List<ProductImage> selectProductImage(int pid){
		List<ProductImage> list=new ArrayList<ProductImage>();
		String sql="select*from product_picture where p_pid="+pid+"";
		ResultSet rs=DBManager.executeQueryUpdate(sql);
		try {
			while(rs.next()){
				ProductImage p=new ProductImage();
				p.setPiid(rs.getInt(1));
				p.setPid(rs.getInt(2));
				p.setPicturesrc(rs.getString(3));
				list.add(p);
			}
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return list;
	}
	public List<Product> selectProduct(int pid){
		List<Product> list=new ArrayList<Product>();
		String sql="select*from product where pid="+pid+"";
		ResultSet rs=DBManager.executeQueryUpdate(sql);
		try {
			while(rs.next()){
				Product p=new Product();
				p.setPid(rs.getInt(1));
				p.setPname(rs.getString(3));
				p.setPmprice(rs.getDouble(6));
				p.setPmodel(rs.getString(12));
				p.setPcolor(rs.getString(11));
				list.add(p);
			}
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return list;
	}

}
